home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / SPRINTF.C < prev    next >
Text File  |  1986-05-18  |  1KB  |  38 lines

  1. /* 1.1  01-08-86                        (sprintf.c)
  2. /************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1984        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10. #include "stdio.h"
  11.  
  12. LOCAL STRING globstr;        /* global string for sputc() deposit    */
  13.  
  14. /************************************************************************/
  15.  
  16. sprintf(str, fmt, args)        /* formatted printf into str string.    */
  17.  
  18. /*----------------------------------------------------------------------*/
  19. STRING str, fmt;
  20. unsigned args;
  21. {
  22.     int sputc(), i;
  23.  
  24.     globstr = str;
  25.     i = format(sputc, fmt, &args);
  26.     *globstr = NULL;
  27.     return i;
  28. }
  29.  
  30. /************************************************************************/
  31.     LOCAL
  32. sputc(c)        /* Put character c into global string globstr.    */
  33.  
  34. /*----------------------------------------------------------------------*/
  35. {
  36.     return (*globstr++ = c) & 0xff;
  37. }
  38.